package utils

import (
	"strconv"
	"unsafe"
)

//将字符串转成int

func StrToInt(str string) int32 {
	value_int64, _ := strconv.ParseInt(str, 10, 64)
	value_int := *(*int32)(unsafe.Pointer(&value_int64))
	return value_int
}

func StrToFloat32(str string) float32 {
	value_float64, _ := strconv.ParseFloat(str, 64)
	//value_float:=*(*float32)(unsafe.Pointer(&value_float64))
	return float32(value_float64)
}

//将字符串切片 转化为 int32 切片
func StrGoInt32(str []string) []int32 {
	var data []int32
	for i := 0; i < len(str); i++ {
		data = append(data, StrToInt(str[i]))
	}
	return data
}
